package tt.dz.vo.request;

import org.apache.commons.lang3.StringUtils;
import tt.dz.biz.annotation.RequestRequire;
import tt.dz.common.BusinessException;
import tt.dz.common.DzErrorCode;
import tt.dz.common.DzErrorCode.CommonErrorCode;

public class ResetPasswordRpcRequestVo
  extends BaseRpcRequestVo
{
  @RequestRequire(required=true)
  private String mobileNo;
  @RequestRequire(required=true)
  private String password;
  @RequestRequire
  private String oldPassword;
  @RequestRequire
  private String checkCode;
  @RequestRequire(required=true)
  private String type;
  @RequestRequire(required=true)
  private String merchantCode;
  
  public void validateRpcRequire()
    throws BusinessException
  {
    super.validateRpcRequire();
    RestPwdType type = RestPwdType.indexOf(getType());
    if (null == type)
    {
      DzErrorCode.CommonErrorCode e = DzErrorCode.CommonErrorCode.FORMAT_ERROR;
      throw new BusinessException(e.value(), e.getDesc(), "当前不存在此重置方法");
    }
    type.validateType(this);
  }
  
  public static enum RestPwdType
  {
    FAST("0", "直接重置") {
		@Override
		public void validateType(ResetPasswordRpcRequestVo paramResetPasswordRpcRequestVo) throws BusinessException {
			// TODO Auto-generated method stub
			
		}
	},  CHECK_CODE("1", "验证码重置") {
		@Override
		public void validateType(ResetPasswordRpcRequestVo paramResetPasswordRpcRequestVo) throws BusinessException {
			// TODO Auto-generated method stub
			
		}
	},  OLD_PASSWOD("2", "原始密码重置") {
		@Override
		public void validateType(ResetPasswordRpcRequestVo paramResetPasswordRpcRequestVo) throws BusinessException {
			// TODO Auto-generated method stub
			
		}
	};
    
    private String value;
    private String desc;
    
    public abstract void validateType(ResetPasswordRpcRequestVo paramResetPasswordRpcRequestVo)
      throws BusinessException;
    
    public static final RestPwdType indexOf(String value)
    {
      if (StringUtils.isEmpty(value)) {
        return null;
      }
      value = value.trim();
      for (RestPwdType type : values()) {
        if (type.value.equals(value)) {
          return type;
        }
      }
      return null;
    }
    
    private RestPwdType(String value, String desc)
    {
      this.value = value;
      this.desc = desc;
    }
  }
  
  public String getMobileNo()
  {
    return this.mobileNo;
  }
  
  public void setMobileNo(String mobileNo)
  {
    this.mobileNo = mobileNo;
  }
  
  public String getPassword()
  {
    return this.password;
  }
  
  public void setPassword(String password)
  {
    this.password = password;
  }
  
  public String getOldPassword()
  {
    return this.oldPassword;
  }
  
  public void setOldPassword(String oldPassword)
  {
    this.oldPassword = oldPassword;
  }
  
  public String getCheckCode()
  {
    return this.checkCode;
  }
  
  public void setCheckCode(String checkCode)
  {
    this.checkCode = checkCode;
  }
  
  public String getType()
  {
    return this.type;
  }
  
  public void setType(String type)
  {
    this.type = type;
  }
  
  public String getMerchantCode()
  {
    return this.merchantCode;
  }
  
  public void setMerchantCode(String merchantCode)
  {
    this.merchantCode = merchantCode;
  }
}
